import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;

public class readFileApplet extends Applet{
  String fileToRead = "statlist_web";
  StringBuffer strBuff;
  TextArea txtArea;
  Graphics g;

  public void init(){

    txtArea = new TextArea(35, 100);
    txtArea.setEditable(false);
    txtArea.setForeground(Color.red);
    txtArea.setBackground(Color.white);
    add(txtArea, "center");
    String prHtml = this.getParameter("fileToRead");
    if (prHtml != null) fileToRead = new String(prHtml);
    readFile();
  }

  public void readFile(){
    String line;
    URL url = null;
    try{
      url = new URL(getCodeBase(), fileToRead);
    }
    catch(MalformedURLException e){}
    
    try{
      InputStream in = url.openStream();
      BufferedReader bf = new BufferedReader(new InputStreamReader(in));
      strBuff = new StringBuffer();
      txtArea.append("\t");
      while((line = bf.readLine()) != null){
        strBuff.append(line + "\n");
	String words[] = line.split(" ");
	for (int i=0; i < words.length; i++){
		
		txtArea.append(words[i].toString());
		txtArea.append("\t   ");
	}
	txtArea.append("\n");
	//txtArea.append(strBuff.toString());
      }
    txtArea.append("\n\nStatistics file name : " + fileToRead + "\n");
    //txtArea.append(strBuff.toString());
    }
    catch(IOException e){
      e.printStackTrace();
    }
  }
}
